package com.hgy.carsb.service;

import com.hgy.carsb.entity.StructureDetail;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class StructureService {
    @Autowired
    private InfoService infoService;

    public StructureDetail getDetail(int year, int month, String zbCode, String prefix){
        String thisYear = infoService.getYearSum(year, month, zbCode, prefix);
        String lastYear = infoService.getYearSum(year-1, 12, zbCode, prefix);
        String thisMonth = infoService.getThisMonth(year, month, zbCode, prefix);
        String lastMonth;
        if (month==1){
            lastMonth = infoService.getThisMonth(year-1, 12, zbCode, prefix);
        }else {
            lastMonth = infoService.getThisMonth(year, month-1, zbCode, prefix);
        }
        StructureDetail structureDetail = new StructureDetail(thisMonth, lastMonth, thisYear, lastYear);
        return structureDetail;
    }
}
